package com.lxg.springboot.mapper;

import com.lxg.springboot.entity.Resource;
import com.lxg.springboot.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author liudongbo
 * @date 2017/9/19 0019下午 2:32
 */
@Repository
public interface ResourceRepository extends JpaRepository<Resource,Long> {
    @Query(value = "SELECT * FROM resource a INNER JOIN role_resource b ON a.id = b.resid INNER JOIN user_role c ON b.rid = c.rid WHERE c.uid = ?1",nativeQuery = true)
    List<Resource> findResByUserId(int uid);
}
